//
//  ACDBOperation.m
//  MonitoringSystem
//  Created by JiaKang.Zhong on 16/5/12.
//  Copyright © 2016年 YTYangK. All rights reserved.
//
#import "ACDBOperation.h"


@interface ACDBOperation (){

//    FMDatabase * db;
}


@end
@implementation ACDBOperation
SINGLETON_M(dbOperation);

- (void) creatDB:(NSString *)dbName{
  
//    db = [FMDatabase databaseWithPath:[ACDocumentPath stringByAppendingPathComponent:dbName]];
}

#pragma mark 创建表
- (void)createWithTableForDB:(NSString *)dbName andTableName:(NSString *)tableName result:(void (^)(BOOL result))result{
    
    // 判断数据库是否存在，不存在创建数据库，存在，直接下一步操作
    if(![ACDocumentPath stringByAppendingPathComponent:dbName]){
        // 创建数据库
        [self creatDB:dbName];
    }
    
    //sql 语句

//        NSString *sqlCreateTable =  [NSString stringWithFormat:@"CREATE TABLE IF NOT EXISTS '%@' ('%@' INTEGER PRIMARY KEY AUTOINCREMENT, '%@' TEXT, '%@' INTEGER, '%@' TEXT)",TABLENAME,ID,NAME,AGE,ADDRESS];
//        BOOL res = [db executeUpdate:sqlCreateTable];
//        if (!res) {
//            NSLog(@"error when creating db table");
//        } else {
//            NSLog(@"success to creating db table");
//        }
//        [db close];
//        
//    }

    
}


#pragma mark 插入数据
- (void)insertDataWithTableName:(NSString *)tableName andEmityObj:(ACDataEntity *)dataEntity result:(void (^)(NSError *))result{
    
    
}

#pragma mark 查询数据
-(NSArray<ACDataEntity *> *)queryDataWithTableName:(NSString *)tableName andIdentifies:(NSString *)deviceIndentifies result:(void (^)(NSError *))result{
    
    return nil;
}

#pragma mark 删除数据
- (void)deleteDataWithTableName:(NSString *)tableName andIdentifies:(NSString *)deviceIndentifies result:(void (^)(NSError *))result{
    
    
    
    
}

@end
